﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Text
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static Dictionary<string, string> users = new Dictionary<string, string>();

        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;


            var usr = users.Where(x => x.Key == uid && x.Value == pwd)
                .Select(x => new { key = x.Key, value = x.Value })
                .FirstOrDefault();




            if (usr != null)
            {
                MessageBox.Show("登录成功");
                MainForm main = new MainForm();
                this.Hide();
                main.Show();
            }
            else
            {
                try
                {
                    if (uid == "")
                    {
                        MessageBox.Show("账号不能为空");
                    }
                    else
                    {
                        if (pwd == "")
                        {
                            MessageBox.Show("密码不能为空!");
                        }
                    }

                }
                finally
                { }
                MessageBox.Show("账号或密码错误，请检查");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Show();
        }
    }
}
